using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using JGSY.CMS.LowCode.Platform.Application.DTOs;

namespace JGSY.CMS.LowCode.Platform.Application.Interfaces
{
    /// <summary>
    /// 团队成员应用服务接口
    /// 提供团队成员管理的业务逻辑
    /// </summary>
    public interface ITeamMemberAppService
    {
        /// <summary>
        /// 获取分页的团队成员列表
        /// </summary>
        /// <param name="query">查询参数</param>
        /// <returns>分页的团队成员列表</returns>
        Task<PagedResultDto<TeamMemberDto>> GetPagedListAsync(PagedQueryDto query);
        
        /// <summary>
        /// 根据团队ID获取成员列表
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <returns>团队成员列表</returns>
        Task<List<TeamMemberDto>> GetByTeamIdAsync(long teamId);
        
        /// <summary>
        /// 根据用户ID获取团队成员信息
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>团队成员列表</returns>
        Task<List<TeamMemberDto>> GetByUserIdAsync(long userId);
        
        /// <summary>
        /// 根据ID获取团队成员详情
        /// </summary>
        /// <param name="id">团队成员ID</param>
        /// <returns>团队成员详情</returns>
        Task<TeamMemberDto?> GetByIdAsync(long id);
        
        /// <summary>
        /// 创建团队成员
        /// </summary>
        /// <param name="dto">团队成员数据</param>
        /// <returns>创建的团队成员</returns>
        Task<TeamMemberDto> CreateAsync(TeamMemberDto dto);
        
        /// <summary>
        /// 更新团队成员
        /// </summary>
        /// <param name="id">团队成员ID</param>
        /// <param name="dto">更新的团队成员数据</param>
        /// <returns>更新后的团队成员</returns>
        Task<TeamMemberDto> UpdateAsync(long id, TeamMemberDto dto);
        
        /// <summary>
        /// 删除团队成员
        /// </summary>
        /// <param name="id">团队成员ID</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteAsync(long id);
        
        /// <summary>
        /// 批量删除团队成员
        /// </summary>
        /// <param name="ids">团队成员ID列表</param>
        /// <returns>删除结果</returns>
        Task<bool> BatchDeleteAsync(List<long> ids);
        
        /// <summary>
        /// 添加用户到团队
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="userId">用户ID</param>
        /// <param name="role">团队角色</param>
        /// <returns>团队成员信息</returns>
        Task<TeamMemberDto> AddMemberAsync(long teamId, long userId, string role = "Member");
        
        /// <summary>
        /// 从团队移除用户
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns>移除结果</returns>
        Task<bool> RemoveMemberAsync(long teamId, long userId);
        
        /// <summary>
        /// 更新团队成员角色
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="userId">用户ID</param>
        /// <param name="role">新角色</param>
        /// <returns>更新结果</returns>
        Task<bool> UpdateMemberRoleAsync(long teamId, long userId, string role);
        
        /// <summary>
        /// 检查用户是否为团队成员
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns>是否为团队成员</returns>
        Task<bool> IsMemberAsync(long teamId, long userId);
        
        /// <summary>
        /// 获取用户在团队中的角色
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns>团队角色</returns>
        Task<string?> GetMemberRoleAsync(long teamId, long userId);
        
        /// <summary>
        /// 获取团队的管理员列表
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <returns>管理员列表</returns>
        Task<List<TeamMemberDto>> GetTeamAdminsAsync(long teamId);
        
        /// <summary>
        /// 批量导入团队成员
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="members">成员数据列表</param>
        /// <returns>导入结果</returns>
        Task<List<TeamMemberDto>> BatchImportAsync(long teamId, List<TeamMemberDto> members);
        
        /// <summary>
        /// 导出团队成员
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <returns>导出数据</returns>
        Task<byte[]> ExportAsync(long teamId);
    }
}
